<?php

include_once 'utiles.php';

require_once("../phpGrid_Basic/conf.php");

 

if (isset($_POST['user'], $_POST['p'], $_POST['empresa'])) {

    $user = $_POST['user'];

    $password = $_POST['p']; // The hashed password.

 		$empresa = $_POST['empresa'];

    if (login($user, $password) == true) {

		    if (empresaOK($user, $empresa) == true) {
		
		        // Login success 
		
		        header('Location: main.php');
		
		    } else {
		
		        // Login failed 
		
		        header('Location: login.php?error=4');
		
		    }

    } else {

        // Login failed 

        header('Location: login.php?error=1');

    }

} else {

    // The correct POST variables were not sent to this page. 

    header('Location: login.php?error=1');

}



?>